add ‘renderMethod’ option for runSass()` to support async custom importer - fix #35 #148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses issue #35, where the usage of a custom importer that is relying on the use of sass's async
render
method throws a 'done
is not a function' error.The error only gets thrown after the stylesheets get rendered, and sass is done with all the sass-true tests, which mean you'd still get the general stats messages (output by sass-true with
@debug
, and listing how many tests were run, how many failed and how many passed).The edits in this PR provide a
renderMethod
option forsassTrue.runSass
which can be set to 'render', in which case sass'srender()
method will be used to run the tests (instead ofrenderSync
). This prevents the 'done
is not a function' error to be thrown, but fails to show the detailed report for which tests pass and which don't (as a matter of fact, it shows '0 passed' at the beginning). The@debug
stats messages are still shown at the end, and return the correct numbers.I suspect this to be because sass-true doesn't wait for the asynchronous sass rendering to show the results. Maybe this is an easy fix, and you can include it in this PR?
PS: I realise the actual issue here is coming from node-sass, but it seems like it's not going to be solved before they release v5.0.0. In the meantime, I tried to improve the support for custom importers in sass-true, and thought I'd share.